//
//  YMMainDefaultEmptyCell.m
//  SmartCar
//
//  Created by y s on 2022/11/21.
//

#import "YMMainDefaultEmptyCell.h"

@interface YMMainDefaultEmptyCell ()

@property (nonatomic, strong) UIImageView *imgvEmpty;
@property (nonatomic, strong) UILabel *lblEmpty;

@end

@implementation YMMainDefaultEmptyCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setUI];
    }
    return self;
}

#pragma mark - UI methods
- (void)setUI{
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    self.contentView.backgroundColor = [UIColor clearColor];
    self.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.imgvEmpty];
    [self.contentView addSubview:self.lblEmpty];
    
    [self.imgvEmpty mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo([SFitUtil fit:100]);
        make.centerX.mas_equalTo(0);
        make.size.mas_equalTo([SFitUtil fitSize:200 height:200]);
    }];
    [self.lblEmpty mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo([SFitUtil fit:15]);
        make.right.mas_equalTo([SFitUtil fit:-15]);
        make.top.equalTo(self.imgvEmpty.mas_bottom);
    }];
    
}
#pragma mark - public methods
+ (CGFloat)getCellHeight{
    return [SFitUtil fit:400];
}
- (void)setStrDes:(NSString *)strDes{
    self.lblEmpty.text = strDes;
}
- (void)setAttrDes:(NSAttributedString *)attrDes{
    _attrDes = attrDes;
    self.lblEmpty.attributedText = attrDes;
    self.lblEmpty.textAlignment = NSTextAlignmentCenter;
    self.lblEmpty.numberOfLines = 0;
}

- (void)tapClickAction{
    if (self.desClickBlock){
        self.desClickBlock();
    }
}

#pragma mark - setter and getter
- (UIImageView *)imgvEmpty{
    if (_imgvEmpty == nil){
        _imgvEmpty = [SThemeUtil icon:@"tools_default_empty_icon"];
    }
    return _imgvEmpty;
}
- (UILabel *)lblEmpty{
    if (_lblEmpty == nil){
        _lblEmpty = [SThemeUtil label:@"" color:STheme.H_D3 fontSize:16];
        _lblEmpty.textAlignment = NSTextAlignmentCenter;
        _lblEmpty.numberOfLines = 0;
        _lblEmpty.userInteractionEnabled = YES;
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapClickAction)];
        [_lblEmpty addGestureRecognizer:tap];
    }
    return _lblEmpty;
}


@end
